//API:move(ele, step, distance, direction, callback)
function move(ele, step, distance, direction, callback) {
    clearInterval(timer); //设置新计时器前先清除
    switch (direction) {
        case "left":
            direction = "left";
            step = -step;
            break;
        case "up":
            direction = "top";
            step = -step;
            break;
        case "right":
            direction = "left";
            break;
        case "down":
            direction = "top";
            break;
    }
    //将输入的参数变为看得懂的形式
    var orin = parseInt(getComputedStyle(ele).getPropertyValue(direction)); //用于储存移动开始时位置
    timer = setInterval(function () {
        var start = parseInt(getComputedStyle(ele).getPropertyValue(direction)); //每次循环的起始位置
        if (start >= orin + distance) {
            ele.style.setProperty(direction, orin + distance + "px");
            clearInterval(timer);
        } else if (start <= orin - distance) {
            ele.style.setProperty(direction, orin - distance + "px");
            clearInterval(timer);
        }
        //超出时停止;
        ele.style.setProperty(direction, start + step + "px");
        //根据步长移动
    }, 10);

    if (callback) callback();
    //如果有毁掉函数则执行
}
